function f = func_Rb(rb_sol,lv,erk,lambda,gamma,delta,sigma_rk)

rkhats_next = log ( rb_sol * (1-1/lv) * ( 1+lambda*(1-gamma) ) - (1-delta) );
z_temp      = (rkhats_next - erk) / sigma_rk;
z_temp_log  = (erk + sigma_rk^2 - rkhats_next) / sigma_rk;

cdf = normcdf(z_temp);
pdf = normpdf(z_temp);
cdf_log = normcdf(z_temp_log);
        
f = rb_sol - ( exp(erk + sigma_rk^2/2) * cdf_log / (1-cdf) + (1-delta) ...
              - lambda * ( rb_sol^2 * (1-gamma) * (1+lambda*(1-gamma)) * (lv-1)/lv^2 ) ...
              / ( rb_sol * (1-1/lv)  * (1+lambda*(1-gamma)) - 1+delta ) /sigma_rk * pdf/(1-cdf) );

end